<template>
	<view>
		<view style="display: flex;flex-direction: row;flex-wrap: wrap; background-color: #fff;">
			<view @click="maskbtnclick(btn[1],'delete')" v-if="isdelete && isaddedit" style="position: absolute;right: 10px;top:10px;color: #f00;" class="iconfont icon-delete"></view>
			<view v-for="(item, index) in datalist" :key="index">
				<view style="display: flex;flex-direction: row;flex-wrap: wrap;" v-if="item.blockName=='addsku_top_image1'" >
					<view style="position: relative;width: 80px;height: 100%;">
						<image :src="pic_address + item.data[0].style.colValue" @error="picerror(index)" style="width: 80px;height: 80px;padding:8px 3px;top: 0;left: 0;"></image> 
					</view>
				</view>
				<view style="width:calc(100vw - 100px) ;height: 100%;padding-left: 8px;padding-top: 10px;" v-if="item.blockName=='addsku_top_line1_nosplit'">
					<view v-for="(gdetail) in item.data" :key='gdetail.name'>
						<view style="color: #666;font-size: 14px; display: flex;flex-direction: row;align-items: center;">
						    <view style="min-width: 16vw;">{{gdetail.style.colText}}:</view>
							<view style="border-radius: 5px;padding: 0 5px;">{{gdetail.style.colValue==null?'':gdetail.style.colValue}}</view>
						</view>
					</view>
				</view>
				<view v-if="item.blockName=='addsku_input_line1'" style="width: 100vw;">
					<view v-for="(item2,index2) in item.data" :key='item2.name'>
							<styledate v-if="item2.style.editStyle=='editmask' && item2.style.colType=='datetime'" 
								:dataobj="item2.style" 
								:divArea='divArea' 
								:pagename='pagename' 
								:listitemindex="index2"
								:listindex = 'listindex'
								:listblockindex="index" 
								:isaddedit='isaddedit'>
							</styledate>
							
							<textdigit v-if="(item2.coltype=='text' || item2.style.editStyle=='' || item2.style.editStyle=='edit' ||  item2.coltype=='digit' || item2.coltype=='number') && item2.style.colVisible" 
								:divArea='divArea' 
								:pagename='pagename' 
								:dataobj="item2.style" 
								:bigdatalist = 'bigdatalist'
								:name="item2.name" 
								:jsonoptions="jsonoptions"  
								:listindex = 'listindex'
								:listitemindex="index2" 
								:listblockindex="index" 
								:isaddedit='isaddedit'>
							</textdigit>
							
							<stylelist v-if="(item2.style.editStyle=='dddw' && item2.style.dddw.name!='d_nvo_uipage_dwc') && item2.style.colVisible" 
								ref="stylelist"  
								:name="item2.name" 
								:divArea='divArea' 
								:pagename='pageName'
								:dataobj="item2.style" 
								:jsonoptions="jsonoptions" 
								:listitemindex="index2" 
								:listindex = 'listindex'
								:listblockindex="index" 
								:bigdatalist = 'datalist'
								:isaddedit='isaddedit'>
							</stylelist>
							
							<styleswitch v-if="item2.style.editStyle=='checkbox'"
								:divArea='divArea' 
								:pagename='pageName'
								:dataobj="item2.style" 
								:jsonoptions="jsonoptions" 
								:listitemindex="index2"
								:listindex = 'listindex'
								:listblockindex="index"
								:isaddedit='isaddedit'>
							</styleswitch>
							
							<stylepicker  v-if="((item2.style.editStyle=='dddw' && item2.style.dddw.name=='d_nvo_uipage_dwc') || item2.style.editStyle=='ddlb' || item2.style.editStyle=='radiobuttons' ) && item2.style.colVisible" 
								ref="stylepicker"  
								:customlist="item2.style.codeTable" 
								:listtype='item2.style.editStyle' 
								:divArea='divArea'
								:pagename='pageName'
								:dataobj="item2.style" 
								:listitemindex="index2"
								:listindex = 'listindex'
								:listblockindex="index" 
								:isaddedit='isaddedit'>
							</stylepicker>
							
							<view v-if="item2.visible && index2!=(data.data.length-1)" style=" height: 1px;width: 100%;border-bottom: #f0f0f0 1px dashed;"></view>
					</view>
				</view>
				</view>
			</view>
			<cover-view style="height: 40px; display: flex;flex-direction: row;align-items: center;justify-content: space-around;position: absolute;bottom: 0;">
				<cover-view @click="maskbtnclick(item2,'')" class="btns" v-for="(item2, index2) in btn" :key="index2" :style="{'background-color':item2.color,'width': (100/btn.length)+'vw'}"  style="text-align:center;line-height:40px; height: 100%; color: #fff;  padding: 5px 0; display: flex;flex-direction: row;align-items: center;justify-content: center;">
					 {{item2.name}}
				</cover-view>
			</cover-view>
		
		
		
		
	</view>
</template>

<script>
export default {
	props:{
		datalist:{
			type:Array
		},
		listindex:{
			type:Number,
			default () {
				return 0
			}
		},
		index:{
			type:Number
		},
		index2:{
			type:Number
		},
		divArea:{
			type:String
		},
		jsonoptions:{
			type:Object
		},
		pic_address:{
			type:String
		},
		parenttype:{
			type:String,
			default () {
				return ''
			}
		},
		isdelete:{
			type:Boolean,
			default () {
				return false
			}
		},
		pagename:{
			type:String
		},
		isaddedit:{
			type:Boolean
		}
	},
	data(){
		return{
			btn:[{'name':'取消','btntype':'cancel','color':'#aaa'},{'name':'确认','btntype':'ensure','color':'#f00'}],
			
		}
	},
	
	mounted:function(res){
		
	},
	
	methods:{
		picerror(index){},
		updatedddwlistvalue(content,index,itemchanged){
			var that = this
			console.log(content)
			that.$refs.stylelist[index].updatedddwlistvalue(content,itemchanged)
		},
		maskbtnclick(item,isdelete){
			var that = this
			var btntype = item.btntype
			if(btntype == 'cancel'){
				uni.$emit("cancelsku")
			}else if(btntype == 'ensure'){
				if(isdelete){
					uni.showModal({
					    title: '提示',
					    content: '确认要删除该行吗?',
						showCancel:true,
						success: function (res) {
							if (res.confirm) {
								uni.$emit("ensuresku", that.datalist,that.parenttype,that.pagename,isdelete)
							}else if (res.cancel) {
								uni.$emit("cancelsku")
							}
						},
					})
				}else{
					uni.$emit("ensuresku", this.datalist,this.parenttype,this.pagename,isdelete)
				}
			}
		}
	}
}
</script>

<style>
</style>